#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <algorithm>

using namespace std;

class A{
public:
    A(){
        p();
    }
    virtual void p(){
        printf("A");
    }
    virtual ~A(){
        p();
    }
};

class B:public A{
public:
    B(){
        p();
    }
    void p(){
        printf("B");
    }
    ~B(){
        p();
    }
};

void test1(){
    A* a=new B();
    delete a;
}


void test2()
{
    vector<int>array;
    array.push_back(100);
    array.push_back(300);
    array.push_back(300);
    array.push_back(300);
    array.push_back(300);
    array.push_back(500);
    vector<int>::iterator itor;
    for(itor=array.begin();itor!=array.end();itor++)
    {
        if(*itor==300)
        {
            itor=array.erase(itor);
        }
    }
    for(itor=array.begin();itor!=array.end();itor++)
    {
        cout<<*itor<<"";
    }
}

void Test1(){
    int n = 0;
    while (cin >> n){
        int ret = -1;
        int count[] = {4,2,3,2};
        if (n > 2)
            ret = count[(n-2) % 4];
        cout << ret << endl;
    }
}


void Test2(){
    string s;
    getline(cin, s);
    char c;
    cin>>c;
    c=tolower(c);
    transform(s.begin(), s.end(), s.begin(), ::tolower);
    int count=0;
    for(int i=0;i<s.size();i++){
        if(s[i]==c) count++;
    }
    cout<<count;
}

int main() {
    test2();
    return 0;
}
